//
//  MineSuggestViewController.m
//  TEst
//
//  Created by   丛熠超 on 2017/4/12.
//  Copyright © 2017年 Tongcheng. All rights reserved.
//意见反馈

#import "MineSuggestViewController.h"
#import "MineSuggestOperator.h"

@interface MineSuggestViewController ()<UITextViewDelegate>
@property (weak, nonatomic) IBOutlet UITextView *SuggestView;
@property (weak, nonatomic) IBOutlet UITextField *ContactField;
@property (weak, nonatomic) IBOutlet UIButton *SendBtn;

@end

@implementation MineSuggestViewController

- (void)setupNavigation
{
    self.navigationItem.title = @"意见反馈";
}

- (void)setupView
{
    _SendBtn.layer.cornerRadius = 10.0;
    _SendBtn.layer.masksToBounds = YES;
    [_SuggestView setScrollEnabled:YES];
    _SuggestView.delegate = self;
    _SuggestView.autoresizingMask = UIViewAutoresizingFlexibleHeight;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self setupNavigation];
    [self setupView];
}
- (void)textViewDidBeginEditing:(UITextView *)textView {
    if ([textView.text isEqualToString:@" 写下对我们的意见和建议吧...."]) {
        textView.text = @"";
    }
}
- (void)textViewDidEndEditing:(UITextView *)textView {
    if (textView.text.length<1) {
        textView.text = @" 写下对我们的意见和建议吧....";
    }
}
- (IBAction)Send:(UIButton *)sender {
    if (self.ContactField.text) {
        NSMutableDictionary *dic = [NSMutableDictionary dictionary];
        dic[@"token"] = self.config.token;
        dic[@"user_id"] = self.config.userId;
        dic[@"Content"] = [NSString stringWithFormat:@"内容：%@ 联系方式：%@", self.SuggestView.text,self.ContactField.text];
        MineSuggestOperator *operator = [[MineSuggestOperator alloc] initWithParams:dic];
        [self.networkingManager asyncTaskOnVC:self operator:operator successBlock:^(BaseModel *baseModel) {
            if ([baseModel.code isEqualToString:@"1"]) {
                [self showToastMessage:baseModel.msg];
                self.SuggestView.text = @" 写下对我们的意见和建议吧....";
                self.ContactField.text = nil;
                [self.navigationController popViewControllerAnimated:YES];
            }
        } failBlock:^(BaseModel *baseModel) {
            
        }];
    }else{
        [self showToastMessage:@"请完善建议内容"];
    }
    
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
